package org.westos.dao;

import org.apache.ibatis.annotations.Param;
import org.westos.pojo.ChuFang;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ChufangDao {
    //医师添加处方到wait_check表
    Integer addChuToWait(ChuFang chuFang);
    //医师从 all_sheet 中查询处方
    List<ChuFang> queryAllSheetByDoc(@Param("doctor") String doctor);
    //医师从wait中查询处方
    List<ChuFang> queryWaitByDoc(@Param("doctor") String doctor);
    //医师从check中查询处方
    List<ChuFang> queryCheckedByDoc(@Param("doctor") String doctor);
    //医师通过id从all_sheet中查询处方
    ChuFang queryAllSheetByDocID(Integer prescription_id, @Param("doctor") String docName);
    //医师通过id从wait中查询处方
    ChuFang queryWaitByDocID(Integer prescription_id, @Param("doctor") String docName);
    //医师通过id从check中查询处方
    ChuFang queryCheckedByDocID(Integer prescription_id, @Param("doctor") String docName);


    //审核医师添加审核通过的处方
    Integer addChecked(ChuFang chuFang);
    //审核医师删除原表中的处方
    Integer deleteWaitChu(Integer prescription_id);
    //审核医师添加审核未通过的处方
    Integer addChuToAll(ChuFang chuFang);
    //审核医师从AllSheet中查询处方
    List<ChuFang> queryAllSheetByAud(@Param("audited") String audited);
    //审核医师从wait中查询处方
    List<ChuFang> queryWaitByAud(@Param("audited") String audited);
    //审核医师从check中查询处方
    List<ChuFang> queryCheckedByAud(@Param("audited") String audited);
    //审核医师通过id从AllSheet中查询处方
    ChuFang queryAllSheetByAudID(Integer prescription_id, @Param("audited") String audName);
    //审核医师通过id从wait中查询处方
    ChuFang queryWaitByAudID(Integer prescription_id, @Param("audited") String audName);
    //审核医师通过id从check中查询处方
    ChuFang queryCheckedByAudID(Integer prescription_id, @Param("audited") String audName);



    //调配药师删除原表中的处方
    Integer deleteCheckedChu(Integer prescription_id);
    //调配医师从checked中查询处方
    List<ChuFang> queryCheckedByAll(@Param("allocate") String allocate);
    //调配医师从AllSheet中查询处方
    List<ChuFang> queryAllSheetByAll(@Param("allocate") String allocate);
    //调配医师通过id从AllSheet中查询处方
    ChuFang queryAllSheetByAllID(Integer prescription_id, @Param("allocate") String allName);
    //调配医师通过id从checked中查询处方
    ChuFang queryCheckedByAllID(Integer prescription_id, @Param("allocate") String allName);

    //发药师从AllSheet中查询处方
    List<ChuFang> queryAllSheetByDis(@Param("distribute") String distribute);
    //发药师通过id从all_sheet中查询处方
    ChuFang queryAllSheetByDisID(Integer prescription_id, @Param("distribute") String disName);

    //从 wait 表中获得最大处方 id
    Integer getMax();
    //从 checked 表中获得最大处方 id
    Integer getMax2();
    //从 all_sheet 表中获得最大处方 id
    Integer getMax3();
}
